<script setup>
import {ref, watch} from 'vue'

const age = ref(18)
//侦听器  侦听age对象，newage 新值 oldage旧值 immediate:true代表立即执行一次，
watch(age, (newage, oldage) => {
  console.log('age', age.value)
  console.log('newage', newage)
  console.log('oldage', oldage)
},{immediate:true})


</script>

<template>
  <button @click="console.log(age)">add</button>
  <button @click="age=99">add+</button>
  {{ age }}
</template>

<style scoped>

</style>
